﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace _1041326_1041339_1041433.AdminPages
{
    public partial class Admin : System.Web.UI.MasterPage
    {
        private string email = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Email"] == null)
            {
                Response.Redirect("~/UserPages/Login.aspx");
                return;
            }

            if (!IsPostBack)
            {
                ShowAuthenticateMessage();
                ShowLogin();
                //DataBind();
            }
        }
        private void ShowAuthenticateMessage()
        {
            if (Session["Email"] != null)
            {
                email = Session["Email"].ToString();
                lbEmail.Text = email;
                LoginPanel.Visible = false;
                AuthenticatedPanel.Visible = true;
            }
        }

        private void ShowLogin()
        {
            if (Session["Email"] == null)
            {

                LoginPanel.Visible = true;
                AuthenticatedPanel.Visible = false;
            }
        }
        protected void lbkLogout_Click(object sender, EventArgs e)
        {
            Session["Email"] = null;
            Session["role"] = null;
            Response.Redirect("~/UserPages/HomePage.aspx");
        }

        protected void LinkHomePage_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/UserPages/HomePage.aspx");
        }
    }
}